Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal uMgs As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function apiSetFocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Public Declare Function apiGetFocus Lib "user32" Alias "GetFocus" () As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Any) As Long
Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
'
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal wndrpcPrev As Long, ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
'
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSrc As Any, ByVal ByteLen As Long)
'
Private Declare Sub OleTranslateColor Lib "oleaut32.dll" (ByVal ColorIn As Long, ByVal hPal As Long, ByRef RGBColorOut As Long)
'
'
' Use to track Multiple DatePicker controls and their subclassing
'
Public scCollection As New Collection
'
' This function is used to allow the user to right click
' on the background of the date-picker, and switch between
' displaying the dropdown button or the spin button
'
Public Function ToggleWinProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
'
Dim mcObj As Object
'
On Error Resume Next
Set mcObj = scCollection.Item("U" & Hex(hwnd))
If mcObj Is Nothing Then Exit Function
On Error GoTo 0
'
Select Case uMsg
Case WM_RBUTTONUP
mcObj.UpDown = Not mcObj.UpDown
Case WM_LBUTTONDOWN
If apiGetFocus <> mcObj.hwnd Then apiSetFocus mcObj.hwnd
Case WM_CHAR
If mcObj.hwnd > 0 Then
' Pass through keys after setting focus to the user control